// *************************************************************************
//
//                                JOST
//
//               Copyright (C) 2007 by Angelo Corsaro.
//                       <angelo.corsaro@gmail.com>
//                          All Rights Reserved.
//
//   Permission to use, copy, modify, and distribute this software and
//   its  documentation for any purpose is hereby  granted without fee,
//   provided that the above copyright notice appear in all copies and
//   that both that copyright notice and this permission notice appear
//   in  supporting  documentation. I don't make  any  representations
//   about the  suitability  of this  software for any  purpose. It is
//   provided "as is" without express or implied warranty.
//
//
// *************************************************************************
//  
// *************************************************************************

#ifndef _JOST_EXCEPTIONS_H_
#define _JOST_EXCEPTIONS_H_

#include <string>

#define DECLARE_JOST_EXCEPTION(ExceptionName)                   \
    namespace jost { class ExceptionName; }                     \
    class jost::ExceptionName : public jost::Exception {	\
    public:                                                     \
            ExceptionName(const std::string& msg) throw();      \
            ~ExceptionName() throw();                           \
    };

#define DEFINE_JOST_EXCEPTION(ExceptionName)                            \
    jost::ExceptionName::ExceptionName(const std::string& msg) throw()  \
        : jost::Exception(msg) {}                                       \
    jost::ExceptionName::~ExceptionName() throw() {} 

namespace jost {
    class Exception;
}


/**
 * The class <code>Exception</code> is the root exception from which
 * all the JOST exceptions are derived.
 * 
 * @author Angelo Corsaro <mailto:angelo.corsaro@gmail.com>
 * @version 0.1 
 */
class jost::Exception : std::exception {
public:
    Exception(const std::string& msg) throw();
    ~Exception() throw();

public:
    /**
     * Returns a description associated with the cause of the
     * exception.
     *
     * @return a description of the exception.
     */ 
    virtual const char* what() const throw();

protected:
    std::string what_;
};



DECLARE_JOST_EXCEPTION(UnknownField)
DECLARE_JOST_EXCEPTION(IllegalTypeConversion)
DECLARE_JOST_EXCEPTION(MalformedJSONStream)
DECLARE_JOST_EXCEPTION(InvalidFormat)

#endif /*_JOST_EXCEPTIONS_H_*/
